package demo1;

import java.util.HashSet;
import java.util.Set;

public class Text {
    public int numJewelsInStones(String jewels, String stones) {
        Set<Character> set = new HashSet<>();
        int count = 0;
        for (int i = 0; i < jewels.length(); i++) {
            char ch = jewels.charAt(i);
            set.add(ch);
        }
        for (int i = 0; i < stones.length(); i++) {
            char ch = stones.charAt(i);
            if(set.contains(ch)) {
                count++;
            }
        }
        return count;
    }
    public int singleNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if(!set.contains(nums[i])) set.add(nums[i]);
            else set.remove(nums[i]);
        }
        for (int i = 0; i < nums.length; i++) {
            if(set.contains(nums[i])) return nums[i];
        }
        return 0;
    }
}
